#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

class Solution {
public:
    bool findNumberIn2DArray(vector<vector<int>>& matrix, int target) {
    
        for(int i = 0;i<matrix.size();++i){
            if(!matrix[i].empty()){
            if(target<*min_element(matrix[i].begin(),matrix[i].end())||target>*max_element(matrix[i].begin(),matrix[i].end())){
                continue;
            }
            else{
                if(find(matrix[i],target)==true){
                    return true;
                }
            }
            }
        }
        return false;

    }
    //对一个数组实现二分查找
    bool find(vector<int>& line,int target){
        int l = 0;
        int r = line.size()-1;
        while(l<=r){
            int mid = (l+r)/2;
            if(line[mid]==target){
                return true;
            }
            else if(line[mid]<target){
                l = mid+1;
            }
            else{
                r = mid-1;
            }
        }
        return false;
    }
};


int main(){
    // vector<vector<int>> V = {{1,4,7,11,15},
    //                         {2,5,8,12,19},
    //                         {3,6,9,16,22},
    //                         {10,13,14,17,24},
    //                         {18,21,23,26,30}};
    vector<vector<int>> V = {{}};

    Solution S;
    cout<<S.findNumberIn2DArray(V,20)<<endl;
}